package com.lzw.config;

import com.lzw.intercept.BaseIntercept;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebMvcConfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 注册拦截器，并配置拦截路径
        registry.addInterceptor(new BaseIntercept())
                .addPathPatterns("/**") // 拦截所有路径
                .excludePathPatterns("/public/**"); // 排除/public路径

        // 你可以注册多个拦截器，它们的执行顺序就是注册的顺序
        // registry.addInterceptor(new AnotherInterceptor())...
    }
}
